﻿using System;
using System.ComponentModel;
using System.Windows.Forms;

namespace zykControl
{
    public partial class FrmZykStyleEditor : Form
    {
        private bool mIsOK;

        /// <summary>ZykDataGrid控件的ZykStyle设置器</summary>
        public FrmZykStyleEditor(ZykDataGrid control, object? value)
        {
            InitializeComponent();
            mControl = control;
            mValue = value;
        }
        private readonly ZykDataGrid mControl;
        private object? mValue;

        /// <summary>
        /// ZykDataGrid控件的ZykStyle设置器
        /// </summary>
        public static bool ShowA(ITypeDescriptorContext? context, IServiceProvider _, object? value)
        {
            if (context?.Instance == null) return false;
            var dI = new FrmZykStyleEditor((ZykDataGrid)context.Instance, value);
            dI.ShowDialog();
            return dI.mIsOK;
        }

        private void BtnClose_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void BtnOK_Click(object sender, EventArgs e)
        {
            mControl.SetZykStyle();
            mIsOK = true;
            var dValue = mValue;
            mValue = dValue;
            Close();
        }
    }
}
